// #ifndef VUE3
import Vue from 'vue'
import App from './App'
import $ from '@/common'

Vue.config.productionTip = false

// 公共methods
Vue.prototype.$go = function (p_url) {
	let arr = p_url.split('?')
	let url = `/pages/${arr[0]}`
	if (arr[1]) {
		url = `/pages/${arr[0]}?${arr[1]}`
	}
	uni.navigateTo({
		url
	});
}
Vue.prototype.$redirectTo = function (p_url) {
	let arr = p_url.split('?')
	let url = `/pages/${arr[0]}`
	if (arr[1]) {
		url = `/pages/${arr[0]}?${arr[1]}`
	}
	uni.redirectTo({
		url
	});
}
Vue.prototype.go = function (url) {
	uni.navigateTo({
		url
	});
}
Vue.prototype.switchTab = function (url) {
	uni.switchTab({
		url
	});
}
Vue.prototype.$switchTab = function (p_url) {
	let arr = p_url.split('?')
	let url = `/pages/${arr[0]}`
	if (arr[1]) {
		url = `/pages/${arr[0]}?${arr[1]}`
	}
	uni.switchTab({
		url
	});
}
Vue.prototype.back = () => {
	let pages = getCurrentPages()
	if (pages.length === 1) {
		uni.switchTab({
			url: '/pages/index'
		});
	} else {
		uni.navigateBack()
	}
}

Vue.prototype.checkLogin = (back = $.noop) => {
	let isLogin = $.getLocal("userId");
	if (!isLogin) {
		Vue.prototype.$switchTab("index");
		return;
	}
	back()
}





Vue.prototype.$ = $






App.mpType = 'app'

const app = new Vue({
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
import App from './App.vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif
